package checksum

import (
	"crypto/sha256"
	"fmt"
	"strings"
)

type Algorithm4SHA256 struct {
	//	是否自动转为大写
	Upper bool
}

// Cal
//
//	@Description:
//	@receiver a
//	@param value
//	@return string
func (a *Algorithm4SHA256) Cal(value string) string {
	hash := sha256.New()
	hash.Write([]byte(value))
	tempValue := fmt.Sprintf("%x", hash.Sum(nil))
	if a.Upper {
		return strings.ToUpper(tempValue)
	}
	return tempValue
}
